package com.example.demo.demos.redis.service;

import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.Set;

@Service
public class LeaderboardService {

    @Resource
    private RedisService redisService;

    // 更新用户的分数
    public void updateUserScore(String leaderboardKey, String userId, double score) {
        redisService.updateLeaderboard(leaderboardKey, userId, score);
    }

    // 获取排行榜前N名
    public Set<Object> getTopUsers(String leaderboardKey, long topN) {
        return redisService.getTopUsersFromLeaderboard(leaderboardKey, topN);
    }

}